chdkfandomcom-20200222-history
UBASIC/Scripts/CanonA640: Motion Detect Video
Motion Detect Video :Written for/on: Canon A640 :Also works on: Other Canon AXXX (Not tested) (A590 tested OK) Motion Detect Video by Johan Van Barel (http://www.vanbarel.tk) The purpose of this script is to record a movie when motion is detected. The screen will be divided into a number of Rows and Columns. The Treshold value determines the treshold for detection. Recommended experimental values are 10=Lightning, 12=Sunshine, 24=Cloudy, 36=Dawn/Dusk. Motion can be detected in the following Modes: 0=U, 1=Y, 2=V, 3=R, 4=G, 5=B. The Pixel Blocksize determines how many pixels are seen as one block. Smaller blocks are more accurate but detection will be slower. The Triggering Delay value should be big enough to avoid shoot-looping after first detection. A value of at least 16 (=1.6 secs) will be ok. The Video Length can be specified in minutes and seconds. If you want to motion-detect for longer periods, you should disable the power-save options of your camera, so that your camera will not power-off after a certain time. ps. for long detection periods you should disable the Power Saving options of your camera. This can be done in the menu. In the Miscellaneous Stuff menu item set the Disable LCD Off value to Script, so the display won't turn off while in mode or while a script is running. Note by Andrew Doran: On my camera (A640) this script was running backwards, shooting video straight away, and stopping when it detected motion. On my copy of the script, I removed the line ' click "shoot_full" ' below the line ' i=0 ' and now it works perfectly. May work differently on different cameras. Note A620 and SD300 also requires removing ' click "shoot_full" ' Documentation/Help (save as MDVideo.txt" file to your /CHDK/SCRIPTS/ folder) ---- Select Movie mode on your Canon A640. Parameters: * Number Of Columns (Default=6) * Number Of Rows (Default=4) * Treshold (0-255) (Default=24) recommended values: 10=Lightning, 12=Sunshine, 24=Cloudy, 36=Dawn/Dusk * Comparison Interval (mSec) (Default=1) * Triggering Delay (.1 Sec) (Default=16) recommended values >= 16 * Pixel BlockSize (Default=8) number of pixels as one block (smaller size is more accurate but slower) * Detection Mode (Default=1) values: 0=U, 1=Y, 2=V, 3=R, 4=G, 5=B * Initial Delay (Sec) (Default=1) * Video length (Min) (Default=0) * Video length (Sec) (Default=10) ---- Script Code (save as "MDVideo.bas" to your /CHDK/SCRIPTS/ folder) rem Johan Van Barel 02-04-2008 rem Motion Detect Video for Canon A640 @title MD Video @param m Video Length (Min) @default m 0 @param s Video Length (Sec) @default s 10 @param a Cols @default a 6 @param b Rows @default b 4 rem Treshold: 10=Lightning, 12=Sunshine, 24=Cloudy, 36=Dawn/Dusk @param c Threshold (0-255) @default c 24 @param d Interval (mSec) @default d 1 @param e Delay (.1 Sec) @default e 16 @param f BlockSize @default f 8 @param g Mode(U=0,Y=1,V=2) @default g 1 @param h Initial Delay (Sec) @default h 1 if m<0 then m=0 if s<0 then s=0 if a<1 then a=1 if b<1 then b=1 if c<0 then c=0 if e<1 then e=1 if f<1 then f=1 if g<0 then g=0 if g>5 then g=5 if h<0 then h=0 l=60000*m+1000*s if l<1000 then l=1000 e=e*100 sleep h*1000 rem time in msecs md will detect x=5000 i=0 click "shoot_full" while 1 t=0 md_detect_motion a, b, g, x, d, c, 1, t, 0, 1, 1, a, b, 0, f, e if t>0 then i=i+1 print "Video", i, "(blocks="; t; ")" click "shoot_full" sleep l click "shoot_full" endif wend Motion Detect Video